import request from '@/config/axios'
import * as classifyApi from '@/api/classify'
import { reactive } from 'vue'

// 查询图片库列表
export const page = async (params: PageParam) => {
  return await request.get({ url: '/picture/page', params })
}

//查询图片分类
export const getPictureClassify = async () => {
  return await classifyApi.classifyTree('picture')
}

export const toAudit = async (params: PageParam) => {
  return await request.post({ url: '/picture/toAudit', data: params })
}

export const audit = async (params: PageParam) => {
  return await request.post({ url: '/picture/audit', data: params })
}

export const back = async (params: PageParam) => {
  return await request.post({ url: '/picture/back', data: params })
}
export const publish = async (ids) => {
  return await request.post({ url: '/picture/publish', data: ids })
}
export const unRelease = async (ids) => {
  return await request.post({ url: '/picture/un/release', data: ids })
}

/**
 * 保存单张图片
 * @param params
 */
export const savePicture = async (params: PageParam) => {
  console.log(params)
  return await request.post({ url: '/picture/save', data: params })
}
/**
 * 图片新建文件夹
 * @param params
 */
export const pictureFolder = async (params) => {
  console.log(params)
  return await request.post({ url: '/picture/folder', data: params })
}
/**
 * 音频新建文件夹
 * @param params
 */
export const audioFolder = async (params) => {
  console.log(params)
  return await request.post({ url: '/audio/folder', data: params })
}
/**
 * 视频新建文件夹
 * @param params
 */
export const videoFolder = async (params) => {
  console.log(params)
  return await request.post({ url: '/video/folder', data: params })
}

/**
 * 根据ID查询
 * @param params
 */
export const selectOne = async (id: String) => {
  return await request.get({ url: '/picture/' + id + '/one' })
}

export const upload = (data) => {
  return request.upload({ url: '/picture/upload', data: data })
}

export const uploadList = (data) => {
  return request.upload({ url: '/picture/uploadList', data: data })
}

export const uploadMaterial = (data) => {
  return request.upload({ url: '/picture/uploadMaterial', data: data })
}

export const selectByDataFieldId = async (id) => {
  return await request.get({ url: '/picture/select/' + id })
}

export const deleted = async (ids) => {
  return await request.delete({ url: '/picture/delete', data: ids })
}

// 查询所有文件附件
export const download = async (resourceId, waterId) => {
  return await request.download({ url: '/picture/download/' + resourceId + '/' + waterId })
}
// 下载带水印图片
export const downloads = async (ids, waterId) => {
  const params = {
    ids: ids
  }
  return await request.download({ url: '/picture/' + waterId + '/downloads', params })
}

// 回收站删除列表查询
export const recycle = async (params: PageParam) => {
  return await request.get({ url: '/picture/recycle', params })
}

// 回收站还原
export const revert = async (ids) => {
  return await request.post({ url: '/picture/revert', data: ids })
}

export const selectDeleted = async (id, deleted) => {
  return await request.get({ url: '/picture/one/' + id + '/' + deleted })
}

// 删除回收站数据
export const deleteByIds = async (ids) => {
  return await request.delete({ url: '/picture/deleteByIds', data: ids })
}

//发布
export const issue = async (ids) => {
  return await request.post({ url: '/picture/issue', data: ids })
}
